<template>
  <div class="mine">
    <div class="title">
      <van-image class="avatar" round fit="cover" :src="info.photo" />

      <div class="info">
        <p class="name">{{ info.name }}</p>
        <p class="data">{{ info.birthday }}</p>
      </div>
    </div>
    <van-row class="my-link">
      <van-col span="8">
        <van-icon name="newspaper-o" />
        <span>我的作品</span>
      </van-col>
      <van-col span="8">
        <van-icon name="star-o" />
        <span>我的收藏</span>
      </van-col>
      <van-col span="8">
        <van-icon name="tosend" />
        <span>阅读历史</span>
      </van-col>
    </van-row>

    <van-cell to="/mine/edit" title="编辑资料" is-link icon="edit" />
    <van-cell to="/mine/chat" title="小智同学" is-link icon="chat-o" />
    <van-cell title="系统设置" is-link icon="setting-o" />
    <van-cell @click="doLogout" title="退出登录" is-link icon="info-o" />
  </div>
</template>

<script>
export default {
  async created() {
    // console.log(111);
    // let res = await userInfoAPI();
    // // console.log(res);
    // this.info = res.data.data;
    // this.$store.commit("setUserInfo", res.data.data);
    this.$store.dispatch("reqUserInfo");
  },
  data() {
    return {};
  },
  computed: {
    info() {
      return this.$store.state.userInfo;
    },
  },
  methods: {
    doLogout() {
      this.$store.commit("logout");
      this.$router.push("/login");
    },
  },
};
</script>

 <style lang="less" scoped>
.mine {
  .title {
    height: 140px;
    background-color: #3296fa;
    display: flex;

    align-items: center;
    .avatar {
      width: 75px;
      height: 75px;
      margin-left: 20px;
      margin-right: 10px;
    }
    .info {
      font-size: 16px;
      color: #fff;
      .name {
        font-weight: 700;
      }
      .data {
        background-color: #fff;
        color: #3296fa;
        margin-top: 5px;
      }
    }
  }
  .my-link {
    margin: 20px 0;
    .van-col {
      display: flex;
      // 切换主轴为y轴
      flex-direction: column;
      align-items: center;
      font-size: 16px;

      .van-icon {
        font-size: 30px;
        margin-bottom: 5px;

        &-newspaper-o {
          color: #8daaff;
        }

        &-star-o {
          color: #ff3800;
        }

        &-tosend {
          color: #ffaf42;
        }
      }
    }
  }
}
</style>